home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / thor / others / uploadfromdopus.thor < prev   
Text File  |  1996-11-10  |  5KB  |  198 lines

  1. /* UploadFromDopus.thor by Troels Walsted Hansen
  2. ** $VER: UploadFromDopus.thor v2.01 (16.01.95)
  3. **
  4. ** An ARexx script that gets the name of selected files in Dopus
  5. ** and creates upload events for those in Thor. Supports the AmiNet
  6. ** standard of getting the short and long description from a special
  7. ** .readme file. If no .readme file is around, the script will attempt
  8. ** to obtain a short description from the filecomment of the file.
  9. **
  10. ** Known to work with DirOpus v4.12.
  11. **
  12. ** New: This version is only for THOR v2.0 or higher.
  13. **
  14. ** New for v2.01: Works with filecomments again.
  15. */
  16.  
  17. /* user variables. edit to your hearts content */
  18.  
  19. bbs = "REQUEST"      /* If you always upload files to the same BBS, */
  20.                      /* change REQUEST to the name of that BBS..    */
  21.  
  22. options results
  23.  
  24. /* needs THOR, bbsread.library and Dopus functions */
  25.  
  26. p = ' ' || address() || ' ' || show('P',,)
  27. thorport = pos(' THOR.',p)
  28.  
  29. if thorport > 0 then thorport = word(substr(p,thorport+1),1)
  30. else
  31. do
  32.     say 'No THOR port found!'
  33.     exit 10
  34. end
  35.  
  36. if ~show('p', 'BBSREAD') then
  37. do
  38.     address command
  39.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  40.         "WaitForPort BBSREAD"
  41. end
  42.  
  43. if ~show('ports','DOPUS.1') then do
  44.     say "DirectoryOpus' ARexx port was not found. Aborting script.."
  45.     exit
  46. end
  47.  
  48. /* main stuff */
  49.  
  50. address DOPUS.1
  51.  
  52. STATUS 7 "-1"
  53. NumberOfSelected = result
  54.  
  55. if(NumberOfSelected = 0) then do
  56.     NOTIFY "Please select some files first..."
  57.     exit
  58. end
  59.  
  60. STATUS 13 "-1"
  61. FilePath = result
  62.  
  63. if(bbs = "REQUEST") then do
  64.     address(bbsread)
  65.     GETBBSLIST stem BBSLIST
  66.     if(rc ~= 0) then
  67.     do
  68.         address(thorport)
  69.         REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  70.         exit 5
  71.     end
  72.  
  73.     address(thorport)
  74.     REQUESTLIST instem BBSLIST title '"Select BBS:"' SIZEGADGET
  75.     if(rc ~= 0) then exit
  76.     else bbs = result
  77. end
  78.  
  79. REQUESTNOTIFY TEXT '"Enable private to conference uploading?"' BT '"_Yes|_No"'
  80. AskForConfname = result
  81.  
  82. address(bbsread)
  83. GETBBSDATA '"'bbs'"' stem BBSDATA
  84.  
  85. address DOPUS.1
  86.  
  87. do i=1 until i = NumberOfSelected
  88.     drop EVENT.
  89.     EVENT.FILEDESCR = ""
  90.  
  91.     GETNEXTSELECTED
  92.     EVENT.FILENAME = result
  93.     EVENT.LOCALFILE = FilePath || EVENT.FILENAME
  94.     orgfilename = EVENT.FILENAME
  95.  
  96.     if(AskForConfname) then do
  97.         address(bbsread)
  98.             GETCONFLIST '"'bbs'"' CONFLIST
  99.         if(rc ~= 0) then
  100.         do
  101.             address(thorport)
  102.             REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  103.             exit 5
  104.         end
  105.  
  106.         address(thorport)
  107.         REQUESTLIST instem CONFLIST title '"Select conf:"' SIZEGADGET
  108.         if(rc ~= 0) then break
  109.         else EVENT.CONFERENCE = result
  110.     end
  111.  
  112.     filenamelength = length(EVENT.FILENAME)
  113.  
  114.         /* this is only a temporary solution */
  115.  
  116.     if(BBSDATA.BBSTYPE = "ABBS"|BBSDATA.BBSTYPE = "ABBS_QWK") then do
  117.         if(filenamelength > 16) then do
  118.             address(thorport)
  119.             REQUESTSTRING TITLE '"Please shorten filename to 16 chars:"' BT '"_Ok|_Cancel"' ID '"'EVENT.FILENAME'"' MAXCHARS 100
  120.             if(rc ~= 0) then exit
  121.             else EVENT.FILENAME = result
  122.         end
  123.     end
  124.  
  125.     if(BBSDATA.BBSTYPE = "MBBS"|BBSDATA.BBSTYPE = "MBBS_QWK") then do
  126.         if(filenamelength > 13) then do
  127.             address(thorport)
  128.             REQUESTSTRING TITLE '"Please shorten filename to 8+3 chars:"' BT '"_Ok|_Cancel"' ID '"'EVENT.FILENAME'"' MAXCHARS 100
  129.             if(rc ~= 0) then exit
  130.             else EVENT.FILENAME = result
  131.         end
  132.     end
  133.  
  134.     address DOPUS.1
  135.     DOPUSTOFRONT
  136.  
  137.     TOPTEXT "Creating upload event for """EVENT.FILENAME"""..."
  138.     EVENT.DETAILEDFILEDESCR = FilePath||substr(EVENT.FILENAME, 1, lastpos(".",EVENT.FILENAME))||"readme"
  139.  
  140.     if exists(EVENT.DETAILEDFILEDESCR) then do
  141.         address(bbsread)
  142.         UNIQUEMSGFILE bbsname '"'bbs'"' stem UNIQUEFILE
  143.         if(rc ~= 0) then
  144.         do
  145.             address(thorport)
  146.             REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  147.             exit
  148.         end
  149.  
  150.         address command 'copy >nil: ' || '"' || EVENT.DETAILEDFILEDESCR || '"' || ' TO ' || '"' || UNIQUEFILE.NAME || '"'
  151.         EVENT.DETAILEDFILEDESCR = UNIQUEFILE.NAME
  152.  
  153.         call open(ReadMe, EVENT.DETAILEDFILEDESCR, R)
  154.  
  155.         do while(~eof(ReadME) & EVENT.FILEDESCR = "")
  156.             Line = readln(ReadMe)
  157.             if(upper(substr(Line,1,6)) = "SHORT:") then EVENT.FILEDESCR = strip(substr(Line,8),B)
  158.         end
  159.  
  160.         call close(ReadMe)
  161.     end
  162.     else drop EVENT.DETAILEDFILEDESCR
  163.  
  164.     if(EVENT.FILEDESCR = "") then do
  165.         address command 'list ' || '"' || FilePath || orgfilename || '"' || ' lformat="%C" >t:TempFilecommentFile'
  166.  
  167.         if(rc = 0) then
  168.         do
  169.             call open(tfh,"t:TempFilecommentFile", R)
  170.                 EVENT.FILEDESCR = readln(tfh)
  171.             call close(tfh)
  172.         end
  173.  
  174.         address command "delete >nil: t:TempFilecommentFile"
  175.  
  176.         if(EVENT.FILEDESCR = "") then do
  177.             address(thorport)
  178.             REQUESTSTRING TITLE '"'||'Enter description for: '||EVENT.FILENAME||'"' BT '"_Ok|_Cancel"' MAXCHARS 40
  179.             if(rc ~= 0) then exit
  180.             else EVENT.FILEDESCR = result
  181.         end
  182.     end
  183.  
  184.     address(bbsread)
  185.     WRITEBREVENT bbsname '"'bbs'"' event 5 stem EVENT
  186.     if(rc ~= 0) then
  187.     do
  188.         address(thorport)
  189.         REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  190.         exit 5
  191.     end
  192.  
  193.     address DOPUS.1
  194.     SELECTFILE '"'orgfilename'"' 0 1
  195. end
  196.  
  197. exit
  198.